import { safeDiv } from '@/util'
export const optionConfig = {
  optionMoney: {
    title: {
      text: '订单金额（元）',
      left: 'left',
      textStyle: {
        fontSize: 16
      }
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      bottom: '1%',
      left: 'center'
    },
    color: ['#F3BD7E', '#6BE3E2', '#006EFF'],
    series: [
      {
        name: '订单金额',
        type: 'pie',
        radius: ['40%', '60%'],
        labelLine: {
          length: 5
        },
        label: {
          formatter: '{c|￥{c}} ', // '{a|{a}}{abg|}\n{hr|}\n  {b|{b}：}{c}  {per|{d}%}
          backgroundColor: '#fff',
          borderWidth: 1,
          borderRadius: 4,
          shadowColor: 'rgba(0, 0, 0, 0.2)',
          shadowBlur: 10,
          padding: [6, 3],
          rich: {
            c: {},
            a: {
              color: '#6E7079',
              lineHeight: 22,
              align: 'center'
            },
            hr: {
              borderColor: '#8C8D8E',
              width: '100%',
              borderWidth: 1,
              height: 0
            },
            b: {
              color: '#4C5058',
              fontSize: 14,
              fontWeight: 'bold',
              lineHeight: 33
            },
            per: {
              color: '#fff',
              backgroundColor: '#4C5058',
              padding: [3, 4],
              borderRadius: 4
            }
          }
        },
        data: []
      }
    ]
  },
  optionNumber: {
    title: {
      text: '订单数量统计（单）',
      left: 'left',
      textStyle: {
        fontSize: 16
      }
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      bottom: '1%',
      left: 'center'
    },
    color: ['#F3BD7E', '#6BE3E2', '#006EFF'],
    series: [
      {
        name: '订单数量',
        type: 'pie',
        radius: ['40%', '60%'],
        labelLine: {
          length: 5
        },
        label: {
          formatter: '{c|{c}单} ', // '{a|{a}}{abg|}\n{hr|}\n  {b|{b}：}{c}  {per|{d}%}
          backgroundColor: '#fff',
          borderWidth: 1,
          borderRadius: 4,
          shadowColor: 'rgba(0, 0, 0, 0.2)',
          shadowBlur: 10,
          padding: [6, 3],
          rich: {
            c: {},
            a: {
              color: '#6E7079',
              lineHeight: 22,
              align: 'center'
            },
            hr: {
              borderColor: '#8C8D8E',
              width: '100%',
              borderWidth: 1,
              height: 0
            },
            b: {
              color: '#4C5058',
              fontSize: 14,
              fontWeight: 'bold',
              lineHeight: 33
            },
            per: {
              color: '#fff',
              backgroundColor: '#4C5058',
              padding: [3, 4],
              borderRadius: 4
            }
          }
        },
        data: []
      }
    ]
  },
  optionGoods: {
    title: {
      show: false
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      show: false
    },
    color: ['#F3BD7E', '#6BE3E2', '#006EFF', '#FC7980'],
    series: [
      {
        name: '商品数量统计',
        type: 'pie',
        radius: ['40%', '55%'],
        labelLine: {
          length: 10
        },
        label: {
          formatter: '{b|{b}}\n{hr|}\n {c|{c}个}', // '{a|{a}}{abg|}\n{hr|}\n  {b|{b}：}{c}  {per|{d}%}
          backgroundColor: '#fff',
          // borderColor: '#8C8D8E',
          borderWidth: 1,
          borderRadius: 6,
          padding: [5, 5],
          shadowColor: 'rgba(0, 0, 0, 0.2)',
          shadowBlur: 10,
          rich: {
            b: {
              color: '#4C5058',
              lineHeight: 22,
              fontSize: 12,
              padding: [5, 6],
              align: 'center'
            },
            hr: {
              borderColor: '#eee',
              width: '100%',
              borderWidth: 1,
              height: 0
            },
            c: {
              color: '#4C5058',
              fontSize: 13,
              fontWeight: 'bold',
              lineHeight: 22,
              align: 'center',
              padding: [2, 6]
            },
            per: {
              color: '#fff',
              backgroundColor: '#4C5058',
              padding: [3, 4],
              borderRadius: 4
            }
          }
        },
        data: []
      }
    ]
  },
  pieData: {
    title: {
      text: '',
      subtext: '',
      left: 'center'
    },
    color: ['#F55F4E', '#FAC85A', '#006EFF'],
    tooltip: {
      trigger: 'item'
    },
    legend: {
      orient: 'horizontal',
      bottom: '3%',
      left: 'center',
      itemWidth: 16,
      itemHeight: 10
    },
    series: [
      {
        name: '数量统计',
        type: 'pie',
        radius: '50%',
        center: ['50%', '43%'],
        data: [],

        label: {
          minMargin: 5,
          edgeDistance: 20,
          lineHeight: 14,
          fontSize: 10,
          color: '#666',

          rich: {
            time: {
              fontSize: 10,
              color: '#999'
            }
          }
        },
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  },
  dataStatistics: {
    title: {
      text: ''
    },
    tooltip: {
      trigger: 'axis'
    },
    legend: {
      data: ['周边游产品', '酒景事业部产品'],
      bottom: '5%',
      left: 'center',
      itemWidth: 16,
      itemHeight: 10
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '18%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: true,
      data: []
      // data: [] //
    },
    yAxis: {
      type: 'value',
      splitLine: {
        show: true,
        lineStyle: {
          type: 'dashed'
        }
      }
    },
    series: [
      {
        name: '周边游产品',
        type: 'line',
        // itemStyle: { normal: { label: { show: true } } },
        data: [],
        label: {
          show: true,
          formatter: ' 流水: {@[1]}\n 订单: {@[2]}',
          lineHeight: 14,
          fontSize: 8,
          color: '#1D6FE9',
          width: 80,
          height: 30,
          backgroundColor: '#fff',
          align: 'left',
          borderRadius: 4,
          shadowColor: 'rgba(0, 0, 0, 0.07)',
          shadowBlur: 5,
          shadowOffsetY: 0.5,
          shadowOffsetX: 0.5
        }
      },
      {
        name: '酒景事业部产品',
        type: 'line',
        data: [],
        label: {
          show: true,
          formatter: ' 流水: {@[1]}\n 订单: {@[2]}',
          lineHeight: 14,
          fontSize: 8,
          color: '#57AE59',
          width: 80,
          height: 30,
          backgroundColor: '#fff',
          align: 'left',
          borderRadius: 4,
          shadowColor: 'rgba(0, 0, 0, 0.07)',
          shadowBlur: 5,
          shadowOffsetY: 0.5,
          shadowOffsetX: 0.5
        }
      }
    ]
  },
  pieVideoData: {
    title: {
      text: '',
      subtext: '',
      left: 'center'
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      orient: 'horizontal',
      bottom: '3%',
      left: 'center'
    },
    series: [
      {
        name: '数量统计',
        type: 'pie',
        radius: '50%',
        data: [
          // { value: 60, name: '未使用' },
          // { value: 60, name: '已退款' },
          // { value: 60, name: '已核销' }
        ],
        label: {
          // alignTo: 'edge',
          formatter: function(data) {
            if (data.name === '未使用') {
              return (data.data.value = data.name)
            } else if (data.name === '已退款') {
              return (data.data.value = data.name)
            }
            // return (data.data.value = data.name + a.a)
            return (data.data.value = data.name + `: ${444}\n金额: ${555}\n订单: ${666}`)
          },
          minMargin: 5,
          edgeDistance: 20,
          lineHeight: 15,
          rich: {
            time: {
              fontSize: 10,
              color: '#999'
            }
          }
        },
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  },
  videoStatistics: {
    title: {
      text: '数据统计'
    },
    tooltip: {
      trigger: 'axis'
    },
    legend: {
      data: ['周边游产品', '酒景事业部产品']
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        name: '周边游产品',
        type: 'line',
        stack: '总量',
        itemStyle: { normal: { label: { show: true } } },
        data: [220, 182, 191, 234, 290, 330, 310]
      },
      {
        name: '酒景事业部产品',
        type: 'line',
        stack: '总量',
        itemStyle: { normal: { label: { show: true } } },
        data: [320, 332, 301, 334, 390, 330, 320]
      }
    ]
  }
}
export const coopStatus = [
  {
    name: '全部',
    value: ''
  },
  {
    name: '合作中',
    value: 0
  },
  {
    name: '已禁用',
    value: 1
  },
  {
    name: '已到期',
    value: 2
  }
]
// 排序规则
export const collation = [
  {
    name: '全部',
    value: ''
  },
  {
    name: '核销金额由高到低',
    value: 0
  },
  {
    name: '退款金额由高到低',
    value: 1
  },
  {
    name: '核销订单由高到低',
    value: 2
  },
  {
    name: '退款订单由高到低',
    value: 3
  }
]

export const colummsConfig = {
  tableColumns: [
    { title: '主播信息', width: 200, dataIndex: 'agentName', scopedSlots: { customRender: 'agentName' } },
    { title: '总销量', dataIndex: 'totalOrderNum', scopedSlots: { customRender: 'totalOrderNum' }, sorter: (a, b) => a.totalOrderNum - b.totalOrderNum },
    {
      title: '总金额',
      dataIndex: 'totalMoney',
      scopedSlots: { customRender: 'totalMoney' },
      sorter: (a, b) => a.totalMoney - b.totalMoney
    },
    { title: '今日销量', scopedSlots: { customRender: 'todayTotalOrderNum' }, dataIndex: 'todayTotalOrderNum', sorter: (a, b) => a.todayTotalOrderNum - b.todayTotalOrderNum },
    {
      title: '今日金额',
      dataIndex: 'todayTotalMoney',
      sorter: (a, b) => a.todayTotalMoney - b.todayTotalMoney,
      scopedSlots: { customRender: 'todayTotalMoney' }
    },
    { title: '状态', fixed: 'right', width: 120, dataIndex: 'cooperationStatus' }
  ],
  goodsTableColumns: [
    { title: '商品名称', width: 150, dataIndex: 'productName' },
    { title: '今日销量', width: 110, dataIndex: 'todayTotalOrderNum', sorter: (a, b) => a.todayTotalOrderNum - b.todayTotalOrderNum },
    { title: '今日核销量', width: 130, dataIndex: 'todayCompleteOrderNum', sorter: (a, b) => a.todayCompleteOrderNum - b.todayCompleteOrderNum },
    { title: '今日退款量', width: 130, dataIndex: 'todayRefundOrderNum', sorter: (a, b) => a.todayRefundOrderNum - b.todayRefundOrderNum },
    { title: '总销量', width: 110, dataIndex: 'totalOrderNum', sorter: (a, b) => a.totalOrderNum - b.totalOrderNum },
    { title: '总核销量', width: 110, dataIndex: 'completeOrderNum', sorter: (a, b) => a.completeOrderNum - b.completeOrderNum },
    { title: '总退款量', width: 110, dataIndex: 'refundOrderNum', sorter: (a, b) => a.refundOrderNum - b.refundOrderNum },
    {
      width: 180,
      slots: { title: 'customTitle' },
      customRender: (data) => {
        if (!data) return '￥0'
        return '￥' + safeDiv(data, 100)
      },
      dataIndex: 'profitMoney',
      sorter: (a, b) => a.profitMoney - b.profitMoney
    },
    { title: '操作', fixed: 'right', width: 90, dataIndex: 'action', scopedSlots: { customRender: 'action' } }
  ],
  platformDimensionList: [
    { title: '站点', width: 180, dataIndex: 'agentName', scopedSlots: { customRender: 'agentName' } },
    { title: '流水', dataIndex: 'totalMoney', scopedSlots: { customRender: 'totalMoney' }, sorter: (a, b) => a.totalMoney - b.totalMoney },
    {
      title: '订单',
      dataIndex: 'totalOrderNum',
      scopedSlots: { customRender: 'totalOrderNum' },
      defaultSortOrder: 'descend',
      sorter: (a, b) => a.totalOrderNum - b.totalOrderNum
    },
    { title: '商品', dataIndex: 'productNum', scopedSlots: { customRender: 'productNum' }, sorter: (a, b) => (a.productNum > b.productNum ? 1 : -1) },
    {
      title: '利润',
      dataIndex: 'profitMoney',
      sorter: (a, b) => a.profitMoney - b.profitMoney,
      scopedSlots: { customRender: 'profitMoney' }
    }
  ],
  videoDimensionList: [
    { title: '视频ID', width: 150, dataIndex: 'agentName', scopedSlots: { customRender: 'agentName' } },
    {
      title: '金额',
      dataIndex: 'totalMoney',
      scopedSlots: { customRender: 'totalMoney' },
      sorter: (a, b) => a.totalMoney - b.totalMoney
    },
    { title: '订单', dataIndex: 'totalOrderNum', scopedSlots: { customRender: 'totalOrderNum' }, defaultSortOrder: 'descend', sorter: (a, b) => a.totalOrderNum - b.totalOrderNu },

    // { title: '商品', scopedSlots: { customRender: 'todayTotalOrderNum' }, dataIndex: 'todayTotalOrderNum', sorter: (a, b) => a.todayTotalOrderNum - b.todayTotalOrderNum },
    {
      title: '视频佣金',
      dataIndex: 'commissionMoney',
      sorter: (a, b) => a.commissionMoney - b.commissionMoney,
      scopedSlots: { customRender: 'commissionMoney' }
    },
    {
      title: '联联利润',
      dataIndex: 'profitMoney',
      sorter: (a, b) => a.profitMoney - b.profitMoney,
      scopedSlots: { customRender: 'profitMoney' }
    }
  ]
}
